//
//  SmallDecisionsZxhOrDmxModelCell.m
//  SmallDecisions
//
//  Created by 李付雄 on 2025/7/25.
//

#import "SmallDecisionsZxhOrDmxModelCell.h"


@interface SmallDecisionsZxhOrDmxModelCell()

@property (nonatomic, strong) UIView *modelTypeView;
@property (nonatomic, strong) UILabel *modelTypeLabel;
@property (nonatomic, strong) UILabel *modelMessageLabel;
@property (nonatomic, strong) UIImageView *modelTypeImageView;

@end

@implementation SmallDecisionsZxhOrDmxModelCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView *selectedBackgroundView = [[UIView alloc] init];
        selectedBackgroundView.backgroundColor = [UIColor clearColor];
        self.selectedBackgroundView = selectedBackgroundView;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}


- (void)setModelParams:(NSDictionary *)modelParams {
    _modelParams = modelParams;
    self.modelTypeLabel.text = modelParams[@"zxhOrDmxText"];
    self.modelMessageLabel.text = modelParams[@"zxhOrDmxContent"];
    self.modelTypeImageView.image = [UIImage imageNamed:modelParams[@"zxhOrDmxIcon"]];

}

- (UIView *)modelTypeView {
    if(!_modelTypeView) {
        _modelTypeView = [[UIView alloc] init];
        _modelTypeView.backgroundColor = SmallDecisionsSecondBgColor;
        _modelTypeView.layer.cornerRadius = 10;
        _modelTypeView.layer.masksToBounds = YES;
        [self.contentView addSubview:_modelTypeView];
        [_modelTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.right.bottom.mas_equalTo(-10);
            make.top.mas_offset(0);
        }];
    }
    return _modelTypeView;
}

- (UIImageView *)modelTypeImageView {
    if(!_modelTypeImageView) {
        _modelTypeImageView = [[UIImageView alloc] init];
        [self.modelTypeView addSubview:_modelTypeImageView];
        [_modelTypeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.mas_equalTo(10);
            make.width.height.mas_equalTo(20);
        }];
    }
    return _modelTypeImageView;
}

- (UILabel *)modelTypeLabel {
    if(!_modelTypeLabel) {
        _modelTypeLabel = [[UILabel alloc] init];
        _modelTypeLabel.font = SmallDecisionsSetBoldFontSize(20);
        _modelTypeLabel.numberOfLines = 0;
        _modelTypeLabel.textColor = SmallDecisionsThemeFontColor;
        [self.modelTypeView addSubview:_modelTypeLabel];
        
        [_modelTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.modelTypeImageView.mas_right).offset(5);
            make.centerY.equalTo(self.modelTypeImageView);
            make.right.mas_equalTo(-10);
        }];
    }
    
    return _modelTypeLabel;
}

- (UILabel *)modelMessageLabel {
    if(!_modelMessageLabel) {
        _modelMessageLabel = [[UILabel alloc] init];
        _modelMessageLabel.font = SmallDecisionsSetFontSize(12);
        _modelMessageLabel.textColor = SmallDecisionsThemeFontColor;
        [self.modelTypeView addSubview:_modelMessageLabel];
        
        [_modelMessageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.modelTypeImageView);
            make.right.equalTo(self.modelTypeLabel);
            make.top.equalTo(self.modelTypeLabel.mas_bottom).offset(10);
            make.bottom.mas_equalTo(-10);
        }];
    }
    
    return _modelMessageLabel;
}

@end
